package day01;

import java.util.Arrays;

/**
 * @author Jetwang
 * @version 1.0
 * @since 2023/3/11 22:08
 * 旋转数组的最小数字
 */
public class Offer11Non {

    public int minArray(int[] numbers) {
        if (numbers.length == 1) {
            return numbers[0];
        }

        int l = 0;
        int r = numbers.length - 1;

        while(l < r) {
            if (numbers[l] < numbers[r]) {
                return numbers[l];
            }
            int mid = (l + r) >>> 1;
            if (numbers[mid] > numbers[l]) {
                l = mid + 1;
            } else if (numbers[mid] < numbers[l]) {
                r = mid;
            } else {
                l++;
            }
        }
        return numbers[l];
    }
}
